package com.xingongchang.baolebei.protocol;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;
import com.insthub.BeeFramework.model.BaseModel;
@Table(name = "Advert")
public class Advert extends BaseModel{
	 @Column(name = "id")
	  public int id;
	 @Column(name = "is_goods")
	  public int is_goods;
//	 @Column(name = "itemid")
//	  public int itemid;
//	 @Column(name = "position")
//	  public int position;
	 @Column(name = "show_img")
	  public String show_img;
	 @Column(name = "title")
	  public String title;
//	 @Column(name = "type")
//	 public int type;
	  public static Advert fromJson(JSONObject jsonObject) throws JSONException {
			if (null == jsonObject) {
				return null;
			}
			Advert localItem = new Advert();
			localItem.id = jsonObject.optInt("id");
			localItem.is_goods = jsonObject.optInt("is_goods");
//			localItem.itemid = jsonObject.optInt("itemid");
//			localItem.position = jsonObject.optInt("position");
//			localItem.type = jsonObject.optInt("type");
			localItem.show_img = jsonObject.optString("show_img");
			localItem.title = jsonObject.optString("title");
			return localItem;
		}

		public JSONObject toJson() throws JSONException {
			JSONObject localItemObject = new JSONObject();
			JSONArray itemJSONArray = new JSONArray();
			localItemObject.put("is_goods", is_goods);
//		    localItemObject.put("itemid", itemid);
			localItemObject.put("show_img", show_img);
			localItemObject.put("title", title);
//			localItemObject.put("type", type);
//		    localItemObject.put("position", position);
			localItemObject.put("id", id);
			return localItemObject;
		}
}
